// 引入SDK核心类，js文件根据自己业务，位置可自行放置
var QQMapWX = require('../../components/libs/qqmap-wx-jssdk');
var qqmapsdk;
// ... 其他代码保持不变 ...

Page({
  data: {
    title: '',
    address: [],
  },
  onLoad: function () {
    // 实例化API核心类
    qqmapsdk = new QQMapWX({
      key: 'RUOBZ-LLW6Q-5755D-4DD53-RCIS2-OSBSS'
    });//dsd
  },
  onShow: function () {
    // 检查并请求位置权限
    wx.getSetting({
      success: (res) => {
        if (!res.authSetting['scope.userLocation']) {
          wx.authorize({
            scope: 'scope.userLocation',
            success: () => {
              //this.searchHotel();
            },
            fail: () => {
              wx.showToast({
                title: '需要位置权限才能使用此功能',
                icon: 'none'
              });
            }
          });
        } else {
          //this.searchHotel();
        }
      }
    });
  },

  searchHotel: function () {

    // 调用接口
    qqmapsdk.search({
      keyword: '厕所',
      success: (res) => {
        console.log(res);
        const result=res.data.map(item=>item.address)
        console.log(result)
        this.setData({
          address:result
        })
      },
      fail: function (res) {
        console.log(res);
      },
      complete: function (res) {
        console.log(res);
      }
    });


  }
});